
#include "../include/Comm.hpp"


int main()
{
    Socket client;
    client.CreateClient(8888, "127.0.0.1");
    std::string requ = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\nhaha";
    while (1)
    {
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        assert(client.Send(requ.c_str(), requ.size()) != -1);
        ssize_t n;
        char buffer[1024] = { 0 };
        assert((n = client.Recv(buffer, sizeof buffer - 1)) != -1);
        buffer[n] = 0;
        std::cout << buffer << std::endl;
        sleep(3);
    }
    client.Close();
    return 0;
}